var Global = function() {
	return {
		init : function() {
			 $.fn.barcodeScanSupport = function(b) {
	                var a = $(this);
	                if (a.attr("barcode-scan-support-done")) {
	                    return this
	                }
	                a.attr("barcode-scan-support-done", true);
	                var c = a.attr("id");
	                if (c == undefined) {
	                    c = "__barcode_" + new Date().getTime();
	                    a.attr("id", c)
	                }
	                if (a.attr("placeholder") == undefined) {
	                    a.attr("placeholder", "支持条码扫描输入;可手工输入按回车键模拟")
	                }
	                if (a.attr("title") == undefined) {
	                    a.attr("title", a.attr("placeholder"))
	                }
	                a.focus(function(d) {
	                    a.select()
	                }).click(function(d) {
	                    if (window.wst) {
	                        window.wst.startupBarcodeScan(c)
	                    }
	                }).keydown(function(d) {
	                    if (b && b.onEnter) {
	                        if (d.keyCode === 13) {
	                            b.onEnter.call(a)
	                        }
	                    }
	                }).bind("barcode",function(d, f) {
	                    a.val(f);
	                    var g = jQuery.Event("keydown");
	                    g.keyCode = 13;
	                    a.trigger(g);
	                    a.select()
	                })
	            }
			
		},
		//消息框
	    notify : function(a,b) {
	    	switch(a) {
	    	   case 'info':
	    		  layer.alert(b,{icon: 1});
	    	   case 'question':
	    		  layer.alert(b,{icon: 3});
	    	   case 'warning':
	    		  layer.alert(b,{icon: 0});  
	    	   case 'error':
	    		  layer.alert(b,{icon: 5});  
	    	} 
	    },
	    //打开加载层
	    blockUI : function(M) {
	    	M = (M == undefined)?"正在拼了命为您加载…":M;
	    	layer.msg(M, {icon: 16});
	    },
	    //关闭加载层
	    unblockUI : function() {
	    	layer.closeAll('loading');
	    },
	    //弹出窗口
	    popWin:function(title,url){
	    	$.get(url, function(str){
	    		layer.open({
	    			type: 1,
	    			area: ['700px', '530px'],
	    			shadeClose: true,
	    		    shade: 0.8,
	    		    maxmin: true,
		    		title:title,
		    		content: str
		    	});  
	    	});
	
	    	      
	    },
	    // 获取Cookie
		getCookie:function(name) {
			if (name != null) {
				var value = new RegExp("(?:^|; )" + encodeURIComponent(String(name)) + "=([^;]*)").exec(document.cookie);
				return value ? decodeURIComponent(value[1]) : null;
			}
		},
		// 移除Cookie
		removeCookie:function(name, options) {
			addCookie(name, null, options);
		}

	    
	}
}();